package com.hmall.search.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hmall.common.dto.Item;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ItemDoc {

    private Long id;//商品id
    private String name;//商品名称
    private Long price;//价格（分）
    private Integer stock;//库存数量
    private String image;//商品图片
    private String category;//分类名称
    private String brand;//品牌名称

    private Integer sold;//销量
    private Integer commentCount;//评论数
    private Integer status;//商品状态 1-正常，2-下架
    @TableField("isAD")
    private Boolean isAD;//商品状态 1-正常，2-下架

    private List<String> suggestion;

    public  ItemDoc(Item item){
        this.id = item.getId();
        this.name = item.getName();
        this.price = item.getPrice();
        this.brand = item.getBrand();
        this.category = item.getCategory();
        this.image=item.getImage();
        this.sold=item.getSold();
        this.commentCount=item.getCommentCount();
        // 组装suggestion
        this.suggestion = Arrays.asList(this.brand, this.category);


    }
}
